package com.aco.party.web.validator.system;

import com.aco.party.web.command.system.EditProductCommand;
import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;

/**
* Created by flying on 3/10/2016 0010.
*/
public class EditProductValidator implements Validator {
@Override
public boolean supports(Class<?> aClass) {
return EditProductCommand.class.isAssignableFrom(aClass);
}

@Override
public void validate(Object o, Errors errors) {
    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "name", "error.name.empty", "名字不能为空");
    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "type", "error.type.empty", "类型不能为空");
    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "process", "error.process.empty", "阶段不能为空");
    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "platformList", "error.platformList.empty", "平台不能为空");
    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "cooperationWays", "error.cooperationWays.empty", "合作方式不能为空");
    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "display", "error.display.empty", "产品展示不能为空");
    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "discription", "error.discription.empty", "产品介绍不能为空");
    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "area", "error.area.empty", "推广区域不能为空");
    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "contact", "error.contact.empty", "联系人不能为空");
    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "phone", "error.phone.empty", "联系方式不能为空");
    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "iconUrl", "error.iconUrl.empty", "图片不能为空");
}
}
